home *** CD-ROM | disk | FTP | other *** search
/ Introduction to 3D Game …ogramming with DirectX 12 / Introduction-to-3D-Game-Programming-with-DirectX-12.ISO / Code.Textures / Chapter 13 The Compute Shader / SobelFilter / SobelFilter.h < prev    next >
Encoding:
C/C++ Source or Header  |  2016-03-02  |  1.7 KB  |  64 lines

  1. //***************************************************************************************
  2. // SobelFilter.h by Frank Luna (C) 2011 All Rights Reserved.
  3. //
  4. // Applies a sobel filter on the topmost mip level of an input texture.
  5. //***************************************************************************************
  6.  
  7. #pragma once
  8.  
  9. #include "../../Common/d3dUtil.h"
  10.  
  11. class SobelFilter
  12. {
  13. public:
  14.     ///<summary>
  15.     /// The width and height should match the dimensions of the input texture to apply the filter.
  16.     /// Recreate when the screen is resized. 
  17.     ///</summary>
  18.     SobelFilter(ID3D12Device* device,
  19.         UINT width, UINT height,
  20.         DXGI_FORMAT format);
  21.         
  22.     SobelFilter(const SobelFilter& rhs)=delete;
  23.     SobelFilter& operator=(const SobelFilter& rhs)=delete;
  24.     ~SobelFilter()=default;
  25.  
  26.     CD3DX12_GPU_DESCRIPTOR_HANDLE OutputSrv();
  27.  
  28.     UINT DescriptorCount()const;
  29.  
  30.     void BuildDescriptors(
  31.         CD3DX12_CPU_DESCRIPTOR_HANDLE hCpuDescriptor, 
  32.         CD3DX12_GPU_DESCRIPTOR_HANDLE hGpuDescriptor,
  33.         UINT descriptorSize);
  34.  
  35.     void OnResize(UINT newWidth, UINT newHeight);
  36.  
  37.     void Execute(
  38.         ID3D12GraphicsCommandList* cmdList, 
  39.         ID3D12RootSignature* rootSig,
  40.         ID3D12PipelineState* pso,
  41.         CD3DX12_GPU_DESCRIPTOR_HANDLE input);
  42.  
  43. private:
  44.     void BuildDescriptors();
  45.     void BuildResource();
  46.  
  47. private:
  48.  
  49.     ID3D12Device* md3dDevice = nullptr;
  50.  
  51.     UINT mWidth = 0;
  52.     UINT mHeight = 0;
  53.     DXGI_FORMAT mFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
  54.  
  55.     CD3DX12_CPU_DESCRIPTOR_HANDLE mhCpuSrv;
  56.     CD3DX12_CPU_DESCRIPTOR_HANDLE mhCpuUav;
  57.  
  58.     CD3DX12_GPU_DESCRIPTOR_HANDLE mhGpuSrv;
  59.     CD3DX12_GPU_DESCRIPTOR_HANDLE mhGpuUav;
  60.  
  61.     Microsoft::WRL::ComPtr<ID3D12Resource> mOutput = nullptr;
  62. };
  63.  
  64.